package com.block.common.enums;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.netty.buffer.PoolSubpageMetric;
import lombok.Data;
import lombok.Getter;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BaseTypeInfoEnum {

    public static void main(String[] args) {

        System.out.println(JSON.toJSONString(ZhimaScore.getDataMap()));
    }

    public static JSONObject resultData = new JSONObject();

    public static List<BaseTypeInfo> multDataList = new ArrayList<>();
    public static List<BaseTypeInfo> singleDataList = new ArrayList<>();

    static {
        //贷款额度
        multDataList.add(
                BaseTypeInfo.build(LoanAmount.baseName, LoanAmount.baseValue, LoanAmount.getDataMap())
        );
        //芝麻分
        multDataList.add(
                BaseTypeInfo.build(ZhimaScore.baseName, ZhimaScore.baseValue, ZhimaScore.getDataMap())
        );

        // 白条
        multDataList.add(
                BaseTypeInfo.build(Baitiao.baseName, Baitiao.baseValue, Baitiao.getDataMap())
        );

        // 花呗
        multDataList.add(
                BaseTypeInfo.build(Huabei.baseName, Huabei.baseValue, Huabei.getDataMap())
        );
        // 学历
        multDataList.add(
                BaseTypeInfo.build(XueLi.baseName, XueLi.baseValue, XueLi.getDataMap())
        );
        //公积金
        multDataList.add(
                BaseTypeInfo.build(Gjj.baseName, Gjj.baseValue,Gjj.getDataMap())
        );
        multDataList.add(
                BaseTypeInfo.build(House.baseName, House.baseValue,House.getDataMap())
        );
        multDataList.add(
                BaseTypeInfo.build(Yuqi.baseName, Yuqi.baseValue,Yuqi.getDataMap())
        );
        multDataList.add(
                BaseTypeInfo.build(Car.baseName, Car.baseValue,Car.getDataMap())
        );
        //保单
        multDataList.add(
                BaseTypeInfo.build(Insurance.baseName, Insurance.baseValue,Insurance.getDataMap())
        );
        //职业
        multDataList.add(
                BaseTypeInfo.build(Job.baseName, Job.baseValue, Job.getDataMap())
        );
        //信用卡额度
        multDataList.add(
                BaseTypeInfo.build(XykErdu.baseName, XykErdu.baseValue, XykErdu.getDataMap())
        );
        multDataList.add(
                BaseTypeInfo.build(SocialInsurance.baseName, SocialInsurance.baseValue, SocialInsurance.getDataMap())
        );



        //企业主
        singleDataList.add(
                BaseTypeInfo.build(EnterpriseOwner.baseName, EnterpriseOwner.baseValue)
        );
//        //公积金
//        singleDataList.add(
//                BaseTypeInfo.build(Gjj.baseName, Gjj.baseValue)
//        );
////        singleDataList.add(
////                BaseTypeInfo.build(Salary.baseName, Salary.baseValue, Salary.getDataMap())
////        );
//        singleDataList.add(
//                BaseTypeInfo.build(House.baseName, House.baseValue)
//        );
////        singleDataList.add(
////                BaseTypeInfo.build(Job.baseName, Job.baseValue, Job.getDataMap())
////        );
//        singleDataList.add(
//                BaseTypeInfo.build(Car.baseName, Car.baseValue)
//        );
//
//        singleDataList.add(
//                BaseTypeInfo.build(SocialInsurance.baseName, SocialInsurance.baseValue)
//        );
//        singleDataList.add(
//                BaseTypeInfo.build(Insurance.baseName, Insurance.baseValue)
//        );
//        // 有无逾期
//        singleDataList.add(
//                BaseTypeInfo.build(Yuqi.baseName, Yuqi.baseValue)
//        );

        resultData.put("multDataList", multDataList);
        resultData.put("singleDataList", singleDataList);

    }


    @Data
    public static class BaseTypeInfo{
        private  String name;
        private  String value;
        private  List<Map<String, String>> itemList;

        public static BaseTypeInfo build(String name, String value, List<Map<String, String>> itemList){
            BaseTypeInfo baseTypeInfo = new BaseTypeInfo();
            baseTypeInfo.setName(name);
            baseTypeInfo.setValue(value);
            baseTypeInfo.setItemList(itemList);
            return baseTypeInfo;
        }

        public static BaseTypeInfo build(String name, String value){
            BaseTypeInfo baseTypeInfo = new BaseTypeInfo();
            baseTypeInfo.setName(name);
            baseTypeInfo.setValue(value);
            return baseTypeInfo;
        }
    }

    @Getter
    public enum LoanAmount{

        la001( "1-3万", "la001", new BigDecimal("30000")),
        la002( "3-5万", "la002", new BigDecimal("50000")),
        la003( "5-10万", "la003", new BigDecimal("100000")),
        la004( "10-20万", "la004", new BigDecimal("200000")),
        la005( "20万以上", "la005", new BigDecimal("250000")),
//        la004( "20万及以上", "la004", new BigDecimal("250000")),
        ;

        public static String baseName = "贷款额度";
        public static String baseValue = "loanAmount";

        String value;
        String name;
        BigDecimal amount;

        LoanAmount(String name, String value, BigDecimal amount){
            this.value = value;
            this.name = name;
            this.amount = amount;
        }

        public static String getNameByValue(String value){
            for (LoanAmount loanAmount: values()){
                if (StrUtil.equals(value, loanAmount.getValue())){
                    return loanAmount.getName();
                }
            }
            return null;
        }

        public static LoanAmount getEntryByValue(String value){
            for (LoanAmount loanAmount: values()){
                if (StrUtil.equals(value, loanAmount.getValue())){
                    return loanAmount;
                }
            }
            return la001;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (LoanAmount item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }


    @Getter
    public enum XykErdu{//信用卡额度

        xy000( "无", "xy000", false),
        xy001( "1-3万", "xy001", true),
        xy002( "3-5万", "xy002", true),
        xy003( "5万以上", "xy003", true),
        ;

        public static String baseName = "信用卡额度";
        public static String baseValue = "xykerdu";

        String value;
        String name;
        boolean showFlag;

        XykErdu(String name, String value, boolean showFlag){
            this.value = value;
            this.name = name;
            this.showFlag = showFlag;
        }

        public static String getNameByValue(String value){
            for (XykErdu item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (XykErdu item: values()){
                if (!item.showFlag)continue;

                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Huabei{

        hb000( "有花呗", "hb000", false),
        hb001( "无", "hb001", true),
        hb002( "1-3万", "hb002", true),
        hb003( "3万-5万", "hb003", true),
        hb004( "5万以上", "hb004", true),
        ;

        public static String baseName = "支付宝花呗";
        public static String baseValue = "huabei";

        String value;
        String name;
        boolean showFlag;

        Huabei(String name, String value, boolean showFlag){
            this.value = value;
            this.name = name;
            this.showFlag = showFlag;
        }

        public static String getNameByValue(String value){
            for (Huabei item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Huabei item: values()){
                if (!item.showFlag)continue;

                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Baitiao{

        bt000( "有白条", "bt000",false),
        bt001( "无", "bt001",true),
        bt002( "1-3万", "bt002", true),
        bt003( "3万-5万", "bt003", true),
        bt004( "5万以上", "bt004", true),
        ;

        public static String baseName = "京东白条";
        public static String baseValue = "baitiao";

        String value;
        String name;
        boolean showFlag;

        Baitiao(String name, String value, boolean showFlag){
            this.value = value;
            this.name = name;
            this.showFlag = showFlag;
        }

        public static String getNameByValue(String value){
            for (Baitiao item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Baitiao item: values()){
                if (!item.showFlag)continue;

                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum ZhimaScore{

        zm000( "有芝麻分", "zm000", false),// 任选一，有芝麻的选项值
        zm001( "无芝麻分", "zm001", false),
        zm002( "1-599分", "zm002", true),
        zm003( "600-649分", "zm003", true),
        zm004( "650-699分", "zm004", true),
        zm005( "700分以上", "zm005", true),
        ;

        public static String baseName = "芝麻分数";
        public static String baseValue = "zhimaScore";

        String value;
        String name;
        boolean showFlag;


        ZhimaScore(String name, String value, boolean showFlag){
            this.value = value;
            this.name = name;
            this.showFlag = showFlag;
        }

        public static String getNameByValue(String value){
            for (ZhimaScore zhimaScore: values()){
                if (StrUtil.equals(value, zhimaScore.getValue())){
                    return zhimaScore.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (ZhimaScore item: values()){
                if (!item.showFlag)continue;

                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }

    }

    @Getter
    public enum Yuqi{

        yq001("有逾期", "yq001"),
        yq002("无逾期", "yq002"),
//        gjj003("连续缴纳6-12个月", "gjj003"),
//        gjj004("连续缴纳1年及以上", "gjj004"),
        ;

        public static String baseName = "有逾期";
        public static String baseValue = "yuqi";

        String value;
        String name;


        Yuqi(String name, String value){
            this.value = value;
            this.name = name;

        }

        public static String getNameByValue(String value){
            for (Yuqi item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Yuqi item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }

    }

    @Getter
    public enum Gjj{

        gjj001("无公积金", "gjj001"),
        gjj002("有公积金", "gjj002"),
        gjj003("6个月以上", "gjj003"),
        gjj004("6个月以下", "gjj004"),
        ;

        public static String baseName = "有公积金";
        public static String baseValue = "gjj";

        String value;
        String name;
        

        Gjj(String name, String value){
            this.value = value;
            this.name = name;
            
        }

        public static String getNameByValue(String value){
            for (Gjj gjj: values()){
                if (StrUtil.equals(value, gjj.getValue())){
                    return gjj.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Gjj item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }

    }

    @Getter
    public enum Salary{

        sl001("0-5000", "sl001"),
        sl002("5000-1万", "sl002"),
        sl003("1万-5万", "sl003"),
        sl004("5万-10万", "sl004"),
        sl005("10万以上", "sl005"),
        ;

        public static String baseName = "薪资";
        public static String baseValue = "salary";

        String value;
        String name;

        Salary(String name, String value){
            this.value = value;
            this.name = name;

        }

        public static String getNameByValue(String value){
            for (Salary salary: values()){
                if (StrUtil.equals(value, salary.getValue())){
                    return salary.getName();
                }
            }
            return null;
        }

        public static Salary getEntryByValue(String value){
            for (Salary item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item;
                }
            }
            return sl003;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Salary item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }


    public enum HaoHanSalary{

        sl020("银行代发", "sl020"),
        sl021("现金发放", "sl021"),
        sl022("个人转账", "sl022"),
        ;

        public static String baseName = "收入形式";
        public static String baseValue = "salary";

        String value;
        String name;


        HaoHanSalary(String name, String value){
            this.value = value;
            this.name = name;
        }

        public static String getNameByValue(String value){
            for (HaoHanSalary salary: values()){
                if (StrUtil.equals(value, salary.getValue())){
                    return salary.getName();
                }
            }
            return null;
        }
        public static HaoHanSalary getEntryByValue(String value){
            for (HaoHanSalary item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item;
                }
            }
            return sl020;
        }

        public String getValue() {
            return value;
        }

        public String getName() {
            return name;
        }

    }

    @Getter
    public enum House{

        hu001( "无房", "hu001"),
        hu002( "有房", "hu002"),//自建房
        ;

        public static String baseName = "有房";
        public static String baseValue = "house";

        String value;
        String name;
        

        House(String name, String value){
            this.value = value;
            this.name = name;
            
        }

        public static String getNameByValue(String value){
            for (House house: values()){
                if (StrUtil.equals(value, house.getValue())){
                    return house.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (House item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Purpose{

        pu001("购房", "pu001"),
        pu002("结婚", "pu002"),
        pu003("消费", "pu003"),
        pu004("教育培训", "pu004"),
        pu005( "购车", "pu005"),
        pu006( "装修", "pu006"),
        ;

        String value;
        String name;

        Purpose(String name, String value){
            this.value = value;
            this.name = name;
        }

        public static Purpose getEntryByValue(String value){
            for (Purpose item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item;
                }
            }
            return pu003;
        }
    }


    @Getter
    public enum Job{

        job001("上班族", "job001"),
        job002("企业主", "job002"),
        job003("自由职业", "job003"),
        job004("其他", "job004"),
        job005("公务员/国企", "job005"),
        ;

        public static String baseName = "工作";
        public static String baseValue = "job";

        String value;
        String name;


        Job(String name, String value){
            this.value = value;
            this.name = name;
        }

        public static String getNameByValue(String value){
            for (Job job: values()){
                if (StrUtil.equals(value, job.getValue())){
                    return job.getName();
                }
            }
            return null;
        }

        public static Job getEntryByValue(String value){
            for (Job item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item;
                }
            }
            return job004;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Job item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Car{

        car001("无车", "car001"),
        car002("有车", "car002"),
//        car003("按揭车", "car003"),
        ;

        public static String baseName = "有车";
        public static String baseValue = "car";

        String value;
        String name;
        

        Car(String name, String value){
            this.value = value;
            this.name = name;
            
        }

        public static String getNameByValue(String value){
            for (Car car: values()){
                if (StrUtil.equals(value, car.getValue())){
                    return car.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Car item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Insurance{

        in001( "无保单", "in001"),
        in002( "有保单", "in002"),
        in003( "2年以上", "in003"),
        in004( "2年以下", "in004"),
        ;

        public static String baseName = "有保单";
        public static String baseValue = "insurance";

        String value;
        String name;


        Insurance(String name, String value){
            this.value = value;
            this.name = name;

        }

        public static String getNameByValue(String value){
            for (Insurance insurance: values()){
                if (StrUtil.equals(value, insurance.getValue())){
                    return insurance.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Insurance item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum SocialInsurance{

        si001( "无社保", "si001"),
        si002( "有社保", "si002"),
        si003( "6个月以上", "si003"),
        si004( "6个月以下", "si004"),
        ;

        public static String baseName = "有社保";
        public static String baseValue = "socialInsurance";

        String value;
        String name;


        SocialInsurance(String name, String value){
            this.value = value;
            this.name = name;

        }

        public static String getNameByValue(String value){
            for (SocialInsurance item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (SocialInsurance item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum EnterpriseOwner{

        eo001( "非企业主", "eo001"),
        eo002( "是企业主", "eo002"),
        ;

        public static String baseName = "是企业主";
        public static String baseValue = "enterpriseOwner";

        String value;
        String name;


        EnterpriseOwner(String name, String value){
            this.value = value;
            this.name = name;

        }

        public static String getNameByValue(String value){
            for (EnterpriseOwner item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (EnterpriseOwner item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum XueLi{

        xl000("有学历", "xl000", false),
        xl001("无", "xl001", true),
        xl002("中专及以下", "xl002", true),
        xl003("大专", "xl003", true),
        xl004("本科", "xl004", true),
        xl005("研究生及以上", "xl005", true),
        ;

        String value;
        String name;
        boolean showFlag;

        public static String baseName = "学历";
        public static String baseValue = "xueli";

        XueLi(String name, String value, boolean showFlag){
            this.value = value;
            this.name = name;
            this.showFlag = showFlag;
        }

        public static XueLi getEntryByValue(String value){
            for (XueLi item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item;
                }
            }
            return xl002;
        }

        public static String getNameByValue(String value){
            for (XueLi item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (XueLi item: values()){
                if (!item.showFlag)continue;

                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }
}
